<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文档标题</title>
    <style>
        #box span {
            color: yellow;
            font-size: 30px;
            background-color: grey;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div id="box">
</div>

<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
<script>
  $(document).ready(function () {
    for (let i = 0; i < 5; i++) {
      $("#box").append($("<span>☆</span>"));
    }

    $("#box span").mouseenter(function () {
      $(this).text("★").prevAll().text("★");
    });

    $("#box span").mouseleave(function () {
      $("#box span").text("☆");
    });
  })
</script>
</body>
</html>
